Creating a 1D Array
In [2]:
import numpy as np
an_array = np.array([1,3,5,7, 9])
print(an_array)
print(type(an_array))
In [4]:
print(an_array.shape)
Creating 2D arrays
In [7]:
twoD_array = np.array([[11,12,13], [21,22,23]])
print(twoD_array)
print(twoD_array.shape)
Many ways to create nd arrays
In [17]:
ex1 = np.zeros([2,2])
print(ex1)
In [18]:
ex2 = np.full((2,2), 9)
print(ex2)
In [22]:
ex3 = np.eye(3,2)
print(ex3)
In [23]:
ex4 = np.ones((1,2))
print(ex4)
In [24]:
ex5 = np.random.random((2,2))
print(ex5)